package com.system.user.dao;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import com.system.user.entity.User;
@org.springframework.stereotype.Repository
public interface UserRepository extends CrudRepository<User, String>,JpaSpecificationExecutor<User>{
	public User findUserByUid(String id);
	public User findUserByUserName(String userName);
	@Query("select c from User c where c.userName = ?1 and c.password =?2")
	public User findUser(String userName,String password);
	@Query("from User user where user.userName = :userName and user.password = :password")
	public User findUser2(@Param("userName")String userName,@Param("password")String password);
	@Query(value = "select * from t_user where userName = ?1",nativeQuery=true)
	public User findUser3(String userName);
	@Modifying
	@Query("update User u set u.password = ?1 where u.uid = ?2")
	public int updateUser(String password,String id);
	@Modifying
	@Query("delete User u where u.uid in (:ids)")
	public int deleteUser(@Param("ids")String[] ids);
	@Query("from User user where user.userName like ?1")
	public Page<User> findPage(String userName,Pageable pageable);
}
